package com.wtwd.campus.utils;
import java.math.BigInteger;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

/**
 * @Author ldaoliang
 * @Date create in 19:18 2021/7/15
 * @Description
 */
public class MD5Utils {

    public static String encode(String value) {
        try {
            MessageDigest messageDigest = MessageDigest.getInstance("md5");
            messageDigest.update(value.getBytes());
            return new BigInteger(1, messageDigest.digest()).toString(16);
        } catch (Exception e) {
            return null;
        }
    }


    public static String encryption(String plainText) {
        String md5 = new String();
        try {
            MessageDigest md = MessageDigest.getInstance("MD5");
            md.update(plainText.getBytes());
            byte b[] = md.digest();
            int i;
            StringBuffer buf = new StringBuffer("");
            for (int offset = 0; offset < b.length; offset++) {
                i = b[offset];
                if (i < 0) {
                    i += 256;
                }
                if (i < 16) {
                    buf.append("0");
                }
                buf.append(Integer.toHexString(i));
            }
            md5 = buf.toString();
        } catch (NoSuchAlgorithmException e) {
            e.printStackTrace();
        }
        return md5;
    }

    public static void main(String[] args) {
    /*    String s = MD5Utils.encode("123");
        String result32 = MD5Utils.encryption("hxy"+"hxy123"+123);
        System.out.println(s);
        System.out.println(result32);*/
  /*      SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String format = sdf.format(new Date(System.currentTimeMillis()));
        System.out.println(format);*/

//        double[] doubles = GPSUtils.gcj02_To_Gps84(22.596775726050062,113.9603679247321);
//        System.out.println(String.valueOf(doubles[1])+","+doubles[0]);
        String res = MD5Utils.encode("ZzAsydyTpM4GMyMu");
        System.out.println(res);
    }
}




